//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
   type:'',
   wdjlCount:0
  },
  //事件处理函数
  To_tjbx: function() {
    wx.navigateTo({
      url: '../tjbx/tjbx'
    })
  },
  To_bxjl:function(){
    wx.navigateTo({
      url: '../bxjl/bxjl'
    })
  },
  To_wxjl:function(){
    wx.navigateTo({
      url: '../AA_wxjl/AA_wxjl'
    })
  },
  To_cjwt: function() {
    wx.navigateTo({
      url: '../cjwt/cjwt'
    })
  },
  To_ssxz: function() {
    wx.navigateTo({
      url: '../ssxz/ssxz'
    })
  },
  onLoad: function () {
    this.setData({type:wx.getStorageSync('type')})
  },
  onReady:function(){
    var that=this
    wx.request({
      url: app.globalData.URL+'/dormitory_repair/query_repair',
      method:"POST",
      data:{
        user_id:wx.getStorageSync('userid'),
        password:wx.getStorageSync('password')
      },
      success:function(res){
        console.log(res)
        for(let i=0;i<res.data.repair_info.length;i++){
          if(res.data.repair_info[i].checked==0&&res.data.repair_info[i].repair_status==1){
             that.data.wdjlCount+=1
          }
        }
        if(that.data.wdjlCount==0){
          wx.removeTabBarBadge({
            index: 1
          })
        }else{
          wx.setTabBarBadge({
            index: 1,
            text: that.data.wdjlCount.toString()
          })
        }
      }
    })
  }
})
